<?php

namespace System\Configure\Adapter;

use Exception;
use System\Yaml\Yaml as YamlParser;
use System\Configure\AdapterAbstract;
use System\Configure\Exception\ParserYamlException;

/**
 * YAML配置文件解析类
 *
 * @package Dream
 * @subpackage Yaml
 * @namespace System\Configure\Adapter
 * @author lewis (lewisld@yeah.net)
 */
class Yaml extends AdapterAbstract
{

    /**
     * 解析YAML配置文件
     *
     * @static
     * @access public
     * @param string $path YAML配置文件路径
     * @return array 返回配置数组
     * @throws ParserYamlException 解析XML配置文件到数组异常
     */
    public static function parser($path)
    {
        try {
            return YamlParser::parser($path);
        } catch (Exception $e) {
            throw new ParserYamlException([
                'message' => 'system.error.conf.parser.yaml',
                'exception' => $e,
                'yamlFile' => $path
            ]);
        }
    }
}
